package org.istone.mylife.core.test.stereotype;

/**
 * @author Stone
 * @date Dec 14, 2011 9:59:52 PM
 */
public class SimpleCalculatorImpl implements SimpleCalculator {

    private double result;

    /**
     * @param number
     */
    @Override
    public SimpleCalculator divide(float number) {
	if (number == 0f)
	    throw new IllegalArgumentException("Divisor can not for 0");
	this.result /= number;
	return this;
    }

    /**
     * @param number
     */
    @Override
    public SimpleCalculator multiply(float number) {
	this.result *= number;
	return this;
    }

    /**
     * @param number
     */
    @Override
    public SimpleCalculator plus(float number) {
	this.result += number;
	return this;
    }

    /**
     * @param number
     */
    @Override
    public SimpleCalculator substract(float number) {
	this.result -= number;
	return this;
    }

    @Override
    public SimpleCalculator clear() {
	this.result = 0;
	return this;
    }

    @Override
    public double getResult() {
	return this.result;
    }

}
